/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.edu.flf.audioteca.businessdelegate.impl;

import br.edu.flf.audioteca.businessdelegate.IAlbumBusinessDelegate;
import br.edu.flf.audioteca.commandcontrol.ComandosDeControle;
import br.edu.flf.audioteca.dao.exceptions.JPAException;
import br.edu.flf.audioteca.entidades.Album;
import br.edu.flf.audioteca.factory.IDAOFactory;
import br.edu.flf.audioteca.factory.impl.DAOFactory;
import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author Nathan Azevedo
 */
public class AlbumBusinessDelegate implements IAlbumBusinessDelegate {

    private static AlbumBusinessDelegate albumBusinessDelegate;
    private IDAOFactory dAOFactory;

    public String gravarAlbum(Album album) {
        dAOFactory = DAOFactory.getInstance();
        try {
            dAOFactory.getAlbumDAO().persistirArtista(album);
        } catch (JPAException ex) {
            Logger.getLogger(AlbumBusinessDelegate.class.getName()).log(Level.SEVERE, null, ex);
            return ComandosDeControle.ERRO_JPA_CADASTRO_ALBUM;
        }
        return ComandosDeControle.MOSTRAR_CADASTRO_DE_ALBUMS;
    }

    public static IAlbumBusinessDelegate getInstance() {
        if (albumBusinessDelegate == null) {
            albumBusinessDelegate = new AlbumBusinessDelegate();
        }
        return albumBusinessDelegate;
    }
}
